package week04.day03;

public class 上级练习题 {
    public static void main(String[] args) {
        //求100-200之间的素数
        int start = 100;
        int end = 200;

        System.out.println("100到200之间的素数有：");
        for (int i = start; i <= end; i++) {
            if (isPrime(i)) {
                System.out.print(i + " ");
            }
        }
    }

    // 判断一个数是否为素数
    public static boolean isPrime(int number) {
        if (number <= 1) {
            return false;
        }

        for (int i = 2; i <= Math.sqrt(number); i++) {
            if (number % i == 0) {
                return false;
            }
        }

        return true;
    }
}
